package com.angel.bo.message.config.socket;

import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;

/**
 * @Author: Haibo.Mei [Haibo.Mei@ge.com]
 * @Description: websocket 配置
 * @Date: 16:50 2018/2/28
 */
@Configuration
@EnableWebSocketMessageBroker
public class WebsocketConfig implements WebSocketMessageBrokerConfigurer {
    @Override
    public void registerStompEndpoints(StompEndpointRegistry stompEndpointRegistry) {
        //解决浏览器跨域的问题
        stompEndpointRegistry.addEndpoint("/angel-websocket").setAllowedOrigins("*").withSockJS();
    }

    @Override
    public void configureMessageBroker(MessageBrokerRegistry registry) {

        registry.setApplicationDestinationPrefixes("/angelapp");
        //配置消息代理（MessageBroker）。
        registry.enableSimpleBroker("/queue","/topic");
    }
}
